// import Vue from "vue";
import echarts from "echarts";
import axios from "axios";
require("echarts-wordcloud");
import simpleBarChart from "components/charts/simple-bar-chart";
import stackedBarChart from "components/charts/stacked-bar-chart";
import areaLineChart from "components/charts/area-line-chart";
import customizedPieChart from "components/charts/customized-pie-chart";
import doughnutPieChart from "components/charts/doughnut-pie-chart";
import circlePieChart from "components/charts/circle-pie-chart";
import lineBarChart from "components/charts/line-bar-chart";
import multipleAreaLineChart from "components/charts/multiple-area-line-chart";
import multipleLineChart from "components/charts/multiple-line-chart";
import pieBarChart from "components/charts/pie-bar-chart";
import simpleLineChart from "components/charts/simple-line-chart";
import wordCloudChart from "components/charts/word-cloud-chart";
import mixChart from "components/charts/mix-chart";
import func from "@utils/func";
// 图表自定义组件
import selectComponent from "components/charts/extra-components/chart-select";
export default {
    install(Vue) {
        let html;
        Vue.prototype.$axios = axios;
        Vue.prototype.$echarts = echarts;
        Vue.component("simple-bar-chart", simpleBarChart);
        Vue.component("stacked-bar-chart", stackedBarChart);
        Vue.component("area-line-chart", areaLineChart);
        Vue.component("customized-pie-chart", customizedPieChart);
        Vue.component("doughnut-pie-chart", doughnutPieChart);
        Vue.component("circle-pie-chart", circlePieChart);
        Vue.component("line-bar-chart", lineBarChart);
        Vue.component("multiple-area-line-chart", multipleAreaLineChart);
        Vue.component("multiple-line-chart", multipleLineChart);
        Vue.component("pie-bar-chart", pieBarChart);
        Vue.component("simple-line-chart", simpleLineChart);
        Vue.component("word-cloud-chart", wordCloudChart);
        Vue.component("mix-chart", mixChart);
        // 图表自定义组件
        Vue.component("chart-select", selectComponent);
        Vue.filter("money", func.price);
        Vue.filter("empty", func.emptyReplace);
        Vue.directive("load", {
            bind(el, binding) {
                html = el.innerHTML;
                console.log(html);
            },
            update(el, binding, vNode) {
                console.log(vNode, "new");
                console.log(el);
                if (binding.value === false) {
                    el.innerHTML = html;
                } else {
                    el.innerHTML = `<div style="background:rgba(0,0,0,0.8);width:100%;position:absolute;top:50%;left:50%;transform:translate(-50%,-50%) "><img style="width:100%" src="http://image.woshipm.com/wp-files/2017/04/bRJBjupXGfmXMTt1uhXS.gif"></div>`;
                }
            },
            unbind(el, binding) {
                if (binding.value === false) {
                    el.innerHTML = html;
                } else {
                    el.innerHTML = `我是true`;
                }
            }
        });
    }
};
